package org.jflame.auth.authc.token;

import java.util.Objects;

/**
 * 用户名密码身份验证token
 * 
 * @author charles.zhang
 */
public class UserPasswordToken implements RememberMeToken {

    private static final long serialVersionUID = 6489329825531123266L;

    private String principal;
    private String credential;
    private String captcha;
    private boolean rememberMe = false;

    public UserPasswordToken() {
    }

    public UserPasswordToken(String userName, String password) {
        this(userName, password, null);
    }

    public UserPasswordToken(String userName, String password, String captcha) {
        Objects.requireNonNull(userName, "userName must be not null");
        Objects.requireNonNull(password, "password must be not null");
        this.principal = userName.trim();
        this.credential = password.trim();
        this.captcha = captcha;
    }

    public String getPrincipal() {
        return principal;
    }

    public String getCredential() {
        return credential;
    }

    public String getCaptcha() {
        return captcha;
    }

    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }

    @Override
    public boolean isRememberMe() {
        return rememberMe;
    }

}
